import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err)
}
import Home from '@/pages/Home'
import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'

export default new VueRouter({
    routes:[
        {
            path: '/home',
            component:Home,
            // 显示和隐藏
            meta: {show: true}
        },
        {
            name:'Search',
            path: '/search/:keyWord?',
            component:Search,
            // 显示和隐藏
            meta: {show: true}
        },
        {
            path: '/login',
            component:Login,
            // 显示和隐藏
            meta: {show: false}
        },
        {
            path: '/register',
            component:Register,
            meta:{show: false}
        },
        {
            // 设置重定向
            path:'/',
            redirect:'/home'
        }
    ]
})